package com.hl.qzzpbackend.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hl.qzzpbackend.common.BaseResponse;
import com.hl.qzzpbackend.common.DeleteRequest;
import com.hl.qzzpbackend.common.ResultUtils;
import com.hl.qzzpbackend.model.dto.industryType.IndustryTypeQueryRequest;
import com.hl.qzzpbackend.model.dto.positionType.PositionTypeAddRequest;
import com.hl.qzzpbackend.model.dto.positionType.PositionTypeQueryRequest;
import com.hl.qzzpbackend.model.dto.positionType.PositionTypeUpdateRequest;
import com.hl.qzzpbackend.model.entity.PositionType;
import com.hl.qzzpbackend.model.vo.IndustryTypeAndPositionTypeVO;
import com.hl.qzzpbackend.model.vo.IndustryTypeVO;
import com.hl.qzzpbackend.model.vo.PositionTypeVO;
import com.hl.qzzpbackend.service.PositionTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 岗位类型 接口
 *
 * @author helong
 */
@Slf4j
@Api(tags = "岗位类型接口")
@RestController
@RequestMapping("/position_type")
public class PositionTypeController {

    @Resource
    private PositionTypeService positionTypeService;

    // 添加岗位类型
    @ApiOperation(value = "添加岗位类型")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public BaseResponse<Boolean> positionTypeAdd(@Valid @RequestBody PositionTypeAddRequest positionTypeAddRequest) {
        if(log.isInfoEnabled()){
            log.info("添加岗位类型 {}", positionTypeAddRequest);
        }
        boolean result = positionTypeService.positionTypeAdd(positionTypeAddRequest);
        return ResultUtils.success(result);

    }

    // 修改岗位类型
    @ApiOperation(value = "修改岗位类型")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResponse<Boolean> positionTypeUpdate(@Valid @RequestBody PositionTypeUpdateRequest positionTypeUpdateRequest) {
        if(log.isInfoEnabled()){
            log.info("修改岗位类型 {}", positionTypeUpdateRequest);
        }
        boolean result = positionTypeService.positionTypeUpdate(positionTypeUpdateRequest);
        return ResultUtils.success(result);
    }


    // 删除岗位类型
    @ApiOperation(value = "删除岗位类型")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public BaseResponse<Boolean> positionTypeDelete(@Valid @RequestBody DeleteRequest deleteRequest) {
        if(log.isInfoEnabled()){
            log.info("删除岗位类型 {}", deleteRequest);
        }
        boolean result = positionTypeService.positionTypeDelete(deleteRequest);
        return ResultUtils.success(result);
    }

    // 岗位类型分页查询
    @ApiOperation(value = "岗位类型分页查询")
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public BaseResponse<Page<PositionTypeVO>> getPositionTypePage(@RequestBody PositionTypeQueryRequest positionTypeQueryRequest) {
        if(log.isInfoEnabled()){
            log.info("岗位类型分页查询 {}", positionTypeQueryRequest);
        }
        Page<PositionTypeVO> pageVO= positionTypeService.getPositionTypePage(positionTypeQueryRequest);
        return ResultUtils.success(pageVO);
    }




}
